// 绝缘电阻结果配置
import type { ConfigItem } from '@/types/tester';
import { formateDateTimeNew, formatUnit, formatString2Number } from './format';
import { unitMap } from '@/config';

export const insulationConfig: ConfigItem[] = [
  {
    label: '测试时间',
    key: 'datetime',
    start: 0,
    length: 7,
    dataType: 'unit8',
    format: formateDateTimeNew,
    description: '测试时间',
    serverKey: 'monitorTime',
  },
  {
    label: '检测位置',
    key: 'location',
    start: 0,
    length: 0,
    dataType: 'char',
    serverKey: 'location',
    editable: true,
    editType: 'select',
    editOptions: ['高对低', '高对中', '中对低', '铁芯', '夹件', '一次对二次极地', '一次对地', '末屏对地', '多节设备', '低压端对地', '中间变一次对二次极地', '极间', '低压端对地', '本体', '底座'],
  },
  {
    label: '温度',
    key: 'temperature',
    start: 0,
    length: 0,
    dataType: 'float',
    precision: 0,
    serverKey: 'temperature',
    editable: true,
    editType: 'input',
    unit: unitMap['0x11'],
    serverFormat: (v) => formatString2Number(v as string),
  },
  {
    label: '环境温度',
    key: 'ambientTemperature',
    start: 0,
    length: 0,
    dataType: 'char',
    serverKey: 'ambientTemperature',
    editable: true,
    editType: 'input',
    unit: unitMap['0x11'],
  },
  {
    label: '空气湿度',
    key: 'airHumidity',
    start: 0,
    length: 0,
    dataType: 'char',
    serverKey: 'airHumidity',
    editable: true,
    editType: 'input',
    unit: unitMap['0x08'],
  },
  {
    label: '备注',
    key: 'remark',
    start: 0,
    length: 0,
    dataType: 'char',
    serverKey: 'remark',
    editable: true,
    editType: 'input',
  },
  {
    label: '预警提示',
    key: 'warnPrompt',
    start: 0,
    length: 0,
    dataType: 'char',
    serverKey: 'warnPrompt',
    hide: true,
    hideInHistory: false,
  },
  {
    label: '测试电压',
    key: 'voltage',
    start: 7,
    length: 4,
    dataType: 'float',
    precision: 2,
    readUnit: 'voltageUnit',
    serverKey: 'voltage',
    serverUnit: unitMap['0x05'],
  },
  {
    label: '试验电压单位',
    key: 'voltageUnit',
    start: 11,
    length: 1,
    dataType: 'unit8',
    format: formatUnit,
    hide: true,
  },
  {
    label: '加压15s绝缘电阻',
    key: 'r15',
    start: 12,
    length: 4,
    dataType: 'float',
    precision: 2,
    readUnit: 'rUnit',
    serverKey: 'insulationResistanceFs',
    serverUnit: unitMap['0x1A'],
  },
  {
    label: '加压60s绝缘电阻',
    key: 'r60',
    start: 16,
    length: 4,
    dataType: 'float',
    precision: 2,
    readUnit: 'rUnit',
    serverKey: 'insulationResistanceSs',
    serverUnit: unitMap['0x1A'],
  },
  {
    label: '加压10min绝缘电阻',
    key: 'r600',
    start: 20,
    length: 4,
    dataType: 'float',
    precision: 2,
    readUnit: 'rUnit',
    serverKey: 'insulationResistanceTm',
    serverUnit: unitMap['0x1A'],
  },
  {
    label: '电阻单位',
    key: 'rUnit',
    start: 24,
    length: 1,
    dataType: 'unit8',
    format: formatUnit,
    hide: true,
  },
  {
    label: '吸收比',
    key: 'absorption',
    start: 25,
    length: 4,
    dataType: 'float',
    precision: 2,
    serverKey: 'absorptance',
  },
  {
    label: '极化指数',
    key: 'polarization',
    start: 29,
    length: 4,
    dataType: 'float',
    precision: 2,
    serverKey: 'polarizationIndex',
  },
];
